{extend name="common:base"}
{block name="content"}
<fieldset class="layui-elem-field layui-field-title">
    <legend>{$title|default='用户管理'}</legend>
</fieldset>
<form action="" class="layui-form" method="post" enctype="multipart/form-data">
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required|titlelength" placeholder="请输入规则名称" autocomplete="on" class="layui-input" {notempty name="oldData.title"} value="{$oldData.title}" {/notempty}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">父规则</label>
        <div class="layui-input-block">
            <select name="pid" lay-filter="">
                <option value="0" selected="">顶级规则</option>
                {notempty name="pTree"}
                {foreach $pTree as $vo}
                    <option value="{$vo.id}" {notempty name="$oldData"}{if ($oldData.pid==$vo.id)} selected=""{/if}{/notempty} >{$vo._title}</option>
                {/foreach}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">规则</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required|namelength" placeholder="请填写规则" autocomplete="off" class="layui-input" {notempty name="oldData.name"} value="{$oldData.name}" {/notempty}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">附加条件</label>
        <div class="layui-input-block">
            <input type="text" name="condition" lay-verify="" placeholder="请输入附加条件" autocomplete="off" class="layui-input" {notempty name="oldData.condition"} value="{$oldData.condition}" {/notempty}>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="checkbox"{notempty name="oldData.is_super"}{if($oldData.status=='启用')}checked=""{/if}{/notempty} name="status" lay-skin="switch" lay-text="启用|禁用" value="1">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">导航</label>
        <div class="layui-input-block">
            <input type="text" name="nav" lay-verify="required" placeholder="请输入菜单标签" autocomplete="on" class="layui-input" {notempty name="oldData.nav"} value="{$oldData.nav}" {/notempty}>
        </div>
    </div>
    {:token()}
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

{/block}
{block name="extend_js"}
<script>
    layui.use(['form','upload','layer'], function() {
        var $=layui.jquery
            ,form = layui.form
            ,upload=layui.upload
            ,layer=layui.layer;
        //定义自定义验证规则
        form.verify({
           titlelength:[/^[\S]{2,12}$/,'规则命名不符合规格']
            ,namelengtn:[/^[\S]{6-80}$/,'规则不能超过80个字符']
        });

//        form.render();
    });
</script>
{/block}